package com.thread.book.book01;

public class Test01 {

    public static void main(String[] args) throws InterruptedException {
        couurne(); //使用线程并发执行
        seriv();   //串行执行
    }

    private static void couurne() throws InterruptedException {
        long start = System.currentTimeMillis();
        long count = 1000000001;
        Thread thread = new Thread(() -> {
            int a = 0;
            for (int i = 0; i < count; i++) {
                a++;
            }
        });
        thread.start();
        int b = 0;
        for (int i = 0; i < count; i++) {
            b--;
        }
        long time = System.currentTimeMillis() - start;
        thread.join();
        System.out.println("concurrency :" + time);
    }


    private static void seriv() {
        long start = System.currentTimeMillis();
        long count = 1000000001;
        int a = 0;
        for (int i = 0; i < count; i++) {
            a++;
        }
        int b = 0;
        for (int i = 0; i < count; i++) {
            b--;
        }
        long time = System.currentTimeMillis() - start;
        System.out.println("concurrency :" + time);
    }

}
